<template>
	<view class="content">
		<view class="content-block">
			<template v-if="list.length>0">
				<view class="info-block" v-for="(item,index) in list" @click="goView(item.jobPublish.id)">
					<view class="info-list">
						<view class="info-item">
							<view class="name-item">
								<view class="name">{{item.jobPublish.jobTitle}}</view>
										<view class="wage" v-if="item.jobPublish.minSalary">{{item.jobPublish.minSalary}}-{{item.jobPublish.maxSalary}}<text class="unit">元</text></view>
										<view class="wage" v-else>面议</view>
							</view>
							<view class="time">投递时间：{{item.formatTime}}</view>
							<view class="welfare-list">
								<!-- <template v-if="item.jobPublish.comRecruiters&&item.jobPublish.comRecruiters.enterprise.welfareList.length>0">
									<view class="welfare-item"
										v-for="(item1,index) in item.jobPublish.comRecruiters.enterprise.welfareList">
										{{item1}}
									</view>
								</template>
								<view v-else>暂无数据</view> -->
							</view>
						</view>
						<view class="time-item">

						</view>
					</view>
					<view class="company-list">
						<image class="company-img" :src="item.jobPublish.comRecruiters?item.jobPublish.comRecruiters.enterprise.logoUrl:''"></image>
						<view class="company-name">{{item.jobPublish.comRecruiters?item.jobPublish.comRecruiters.enterprise.enterpriseName:''}}
						</view>
					</view>
				</view>
			</template>
			<view v-else-if="list.length>0&&!more" style="text-align: center;">没有更多了哦</view>
			<view v-else style="text-align: center;">暂无数据</view>
		</view>
	</view>
	</view>
</template>

<script>
	import {
		getStorage
	} from '@/util/auth.js';
	import {
		isMore
	} from '@/util/util.js'
	import {
		getWorkApplyByCustomerApi
	} from '@/api/count_details.js';
	import util from '@/util/util.js';
	export default {
		data() {
			return {
				imageUrl: '',
				list: [],
				page: 1,
				limit: 10,
				more: true,
				total: 0,
			}
		},
		methods: {
			navigate(url) {
				uni.navigateTo({
					url
				})
			},
			//浏览求职者
			goView(id) {
				uni.navigateTo({
					url: '/page_other/job_hunting/job_detail/index?id=' + id + '&jobType=' + item.jobType
				})
			},
			refresh() {
				this.page = 1
				this.more = true
				this.getList(true);
			},
			async getList(refresh = false) {
				if (this.more) {
					let config = {
						page: this.page,
						limit: this.limit
					}
					uni.showLoading({
						title: '加载中',
						mask: true
					})
					let res = await getWorkApplyByCustomerApi(config)
					console.log(res)
					let list = res.list ?? [];
					this.list = refresh ? list : [...this.list, ...list],
						this.total = res.count
					this.more = isMore(this.page, this.limit, this.total)
				}
			}
		},

		onLoad(options) {
			this.imageUrl = this.globalConfig.imageUrl;
			this.getList(true);
		},

		onPullDownRefresh() {
			this.refresh();
			uni.stopPullDownRefresh();
		},
		onReachBottom() {
			if (this.more) {
				this.page++;
				this.getList()
			}
		},
	}
</script>

<style lang="scss">
	$box-shadow: 0 0 10px 0 #efefef;

	page {
		background: #FAFAFA;
	}

	.content {
		width: 100%;
		padding: 30rpx;

		.loadingicon {
			width: 100%;
			height: 80rpx;
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			justify-content: center;
		}

		.loading {
			width: 100%;
			height: 100rpx;
			line-height: 100rpx;
			align-items: center;
			justify-content: center;
			position: relative;
			text-align: center;
		}

		.loading .line {
			position: absolute;
			width: 450rpx;
			left: 150rpx;
			top: 50rpx;
			height: 1px;
			border-top: 1px solid #eee;
		}

		.loading .text {
			position: relative;
			display: inline-block;
			padding: 0 20rpx;
			background: #fff;
			z-index: 2;
			color: #777;
		}

		.loadingicon .loading {
			animation: load linear 1s infinite;
			font-size: 45rpx;
			color: #000;
		}

		.loadingicon {
			width: 100%;
			height: 80rpx;
		}

		.block {
			width: 100%;
			margin-bottom: 20rpx;
			position: relative;
		}

		.info-block {
			width: 100%;
			margin-bottom: 20rpx;
			position: relative;
			display: flex;
			flex-direction: column;
			background: #fff;
			padding: 20rpx;

			.info-list {
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				padding: 20rpx;

				.info-item {
					width: 100%;
					display: flex;
					flex-direction: column;

					.name-item {
						width: 100%;
						display: flex;
						flex-direction: row;
						font-size: 38rpx;
						font-weight: bold;
						justify-content: space-between;

						.name {
							width: calc(100% - 290rpx);
							display: flex;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
						}

						.wage {
							color: #FE7526;
							font-size: 32rpx;
						}

						.unit {}
					}

					.time {
						font-size: 26rpx;
						margin-top: 25rpx;
					}

					.welfare-list {
						display: flex;
						flex-direction: row;
						flex-wrap: wrap;
						justify-content: left;
						font-size: 24rpx;
						margin-top: 20rpx;

						.welfare-item {
							padding: 8rpx 20rpx;
							background: #F5F6F8;
							color: #999;
							margin: 0 10rpx 20rpx 0;
						}
					}
				}

			}

			.company-list {
				display: flex;
				flex-direction: row;
				align-items: center;

				.company-img {
					width: 90rpx;
					height: 90rpx;
					border-radius: 50%;
					margin-right: 20rpx;
				}

				.company-name {
					width: calc(100% - 110rpx);
					font-size: 32rpx;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}
			}
		}
	}
</style>
